﻿using System.Collections.Generic;
using System.Net;

namespace GraphicsServer
{
    static class SubscriberList
    {
        static readonly List<EndPoint> _subscribersList = new List<EndPoint>();

        static public List<EndPoint> GetSubscribers()
        {
            lock (typeof(SubscriberList))
            {
                return _subscribersList;
            }
        }

        static public void AddSubscriber(EndPoint subscriberEndPoint)
        {
            lock (typeof(SubscriberList))
            {
                if (!_subscribersList.Contains(subscriberEndPoint))
                {
                    _subscribersList.Add(subscriberEndPoint);
                }
            }
        }

        static public void RemoveSubscriber(EndPoint subscriberEndPoint)
        {
            lock (typeof(SubscriberList))
            {
                if (!_subscribersList.Contains(subscriberEndPoint)) return;

                _subscribersList.Remove(subscriberEndPoint);
            }
        }
    }
}
